UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'EF84YMYnRc6rOWhq83A9yfsEw/kzyFQfz87MDfZp/+w=' 
WHERE 
  key_id = '59ebccba31a45177c21100f879423513e76919d2a29d7bbb54e1d362a7e45374' 
  AND (
    token = 'EF84YMYnRc6rOWhq83A9yfsEw/kzyFQfz87MDfZp/+w=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038