UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ahYVTfdsl3ekBch/50010VF6uroTiDqhxQlAPVcexzw=' 
WHERE 
  key_id = '9f8121c98e529b61082de84bc370c2532021f215e194d96027f4159e104d82fe' 
  AND (
    token = 'ahYVTfdsl3ekBch/50010VF6uroTiDqhxQlAPVcexzw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022