UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O7oVcD38qkJZCAQV1MvCUJ6oLRlXj/cdjwXSt2r7UOI=' 
WHERE 
  key_id = 'b40da7880d9e1a58df3051660d0336fc2f4387177c330a96296f5f2c77b955ee' 
  AND (
    token = 'O7oVcD38qkJZCAQV1MvCUJ6oLRlXj/cdjwXSt2r7UOI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00170