UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'h4ACjneNiE6Xu114B21dY6ywZivIozIKoWrDFCbDZis=' 
WHERE 
  key_id = '4a5045da558b48dfea586c5328abbb79bc539bdf3b59b616ef994e918468e924' 
  AND (
    token = 'h4ACjneNiE6Xu114B21dY6ywZivIozIKoWrDFCbDZis=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025