UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ldL86Q7XUKKHC9vWUrkgcAmSB0XJIbY4ij5+jyg+Gps=' 
WHERE 
  key_id = '77fb0310e46454573d33947b6eec0a7eee0326058bd6b13f186733d7c6260968' 
  AND (
    token = 'ldL86Q7XUKKHC9vWUrkgcAmSB0XJIbY4ij5+jyg+Gps=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026